package project2;

import misc.not_Legal_Exception;
import evolution_superclasses.Genotype;
import evolution_superclasses.Phenotype;

public class spiking_neuron_genotype extends Genotype {
	protected int[] _params;

	public spiking_neuron_genotype(int size) {
		super(size);
	}

	public int[] get_params() {
		return _params;
	}

	public void set_params(int[] params) {
		_params = params;
	}

	public void edit_params(int index, int param) {
		_params[index] = param;
	}

	@Override
	public void createGenotype(int size) throws not_Legal_Exception {
		_params = new int[size];
		for(int i = 0; i < size; i++)
			createRandomForPosistion(i);
	}
	
	//To ease development into phenotypes, make sure they only have to be divided by 1000.
	public int createRandomForPosistion(int pos){
		switch (pos) {
		case 0:
			_params[0] = _rand.nextInt(199)+1; 	//[0.001; 0.2]
			return _params[0];
		case 1:
			_params[1] = _rand.nextInt(290)+10; 	//[0.01; 0.3]
			return _params[1];
		case 2:
			_params[2] = (_rand.nextInt(5000)-8000)*10;	//[-80; -30]   (0 to 50 minus 80)
			return _params[2];
		case 3:
			_params[3] = (_rand.nextInt(990)+10)*10; 	//[0.1; 10]
			return _params[3];
		case 4:
			_params[4] = _rand.nextInt(990)+10; 	//[0.01; 1]
			return _params[4];
		default:
			return 0;
		}
	}

	@Override
	public Phenotype generatePhenotype() {
		set_phenotype(new spiking_neuron_phenotype(this));
		return get_phenotype();
	}

	@Override
	public String toString() {
		String s = "";
		for(int i:_params)
			s += i+" ";
		return s;
	}

}
